/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TieBreakTrainingTeamsAndCoaches.java
 *
 * Created on 24-03-2011, 11:02:55
 */

package tiebreak.UI;

import java.sql.SQLException;
import javax.swing.DefaultComboBoxModel;
import tiebreak.BL.Training;
import tiebreak.be.Team;

/**
 *
 * @author henrikhansen
 */
public class TieBreakTrainingTeamsAndCoaches extends javax.swing.JPanel {
    int teamID;
    /** Creates new form TieBreakTrainingTeamsAndCoaches */
    public TieBreakTrainingTeamsAndCoaches(String coache, int coach) throws SQLException {
        initComponents();
        lblCoach.setText(coache);
        fillList();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblSelteam = new javax.swing.JLabel();
        cbTeams = new javax.swing.JComboBox();
        lblCoach = new javax.swing.JLabel();

        setEnabled(false);
        setPreferredSize(new java.awt.Dimension(50, 110));
        setSize(new java.awt.Dimension(300, 300));

        lblSelteam.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        lblSelteam.setText("Select team for ");

        lblCoach.setText("jLabel1");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(lblSelteam))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(lblCoach))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(20, 20, 20)
                        .add(cbTeams, 0, 363, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(lblSelteam)
                .add(1, 1, 1)
                .add(lblCoach)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbTeams, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(20, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cbTeams;
    private javax.swing.JLabel lblCoach;
    private javax.swing.JLabel lblSelteam;
    // End of variables declaration//GEN-END:variables

    private void fillList() throws SQLException {
        DefaultComboBoxModel dcbm = new DefaultComboBoxModel();
            for(Team teams : Training.getTeams())
            {
                dcbm.addElement(teams.getName());
                teamID = teams.getID();
            }
        cbTeams.setModel(dcbm);
    }

    public int getTeamID()
    {
        return teamID;
    }

    public String getSelectedTeam()
    {
        return cbTeams.getSelectedItem().toString();
    }

}
